import 'package:get/get.dart';
import 'package:mokeng/models/entities.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

class MatchController extends GetxController {
  RxList<MatchInfo> data = <MatchInfo>[].obs;

  /// UI 组件
  final RefreshController refreshController = RefreshController(
    initialRefresh: true,
  );

  /// 事件

  void onRefresh() async {
    await Future.delayed(const Duration(milliseconds: 1000));
    data.clear();
    data.add(MatchInfo(
      name: "赢元气森林设计大赛获百万大奖",
      time: "2024-06-07 - 2024-07-30",
      leftTime: "19",
      count1: 100,
      count2: 100,
      count3: 100,
      image: "assets/images/banner_1.png",
    ));
    data.add(MatchInfo(
      name: "元气森林谷子设计大赛",
      time: "2024-06-07 - 2024-07-30",
      leftTime: "19",
      count1: 100,
      count2: 100,
      count3: 100,
      image: "assets/images/banner_2.png",
    ));
    data.add(MatchInfo(
      name: "元气森林吧唧设计大赛",
      time: "2024-06-07 - 2024-07-30",
      leftTime: "19",
      count1: 100,
      count2: 100,
      count3: 100,
      image: "assets/images/banner_3.png",
    ));
    refreshController.refreshCompleted();
  }

  /// 生命周期

  ///dispose 释放内存
  @override
  void dispose() {
    super.dispose();
    // dispose 释放对象
    refreshController.dispose();
  }
}
